package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.OrderStafforder;
import com.ruoyi.system.service.IOrderStafforderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 员工管理Controller
 * 
 * @author ruoyi
 * @date 2024-10-23
 */
@RestController
@RequestMapping("/system/stafforder")
public class OrderStafforderController extends BaseController
{
    @Autowired
    private IOrderStafforderService orderStafforderService;

    /**
     * 查询员工管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:stafforder:list')")
    @GetMapping("/list")
    public TableDataInfo list(OrderStafforder orderStafforder)
    {
        startPage();
        List<OrderStafforder> list = orderStafforderService.selectOrderStafforderList(orderStafforder);
        return getDataTable(list);
    }

    /**
     * 导出员工管理列表
     */
    @PreAuthorize("@ss.hasPermi('system:stafforder:export')")
    @Log(title = "员工管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, OrderStafforder orderStafforder)
    {
        List<OrderStafforder> list = orderStafforderService.selectOrderStafforderList(orderStafforder);
        ExcelUtil<OrderStafforder> util = new ExcelUtil<OrderStafforder>(OrderStafforder.class);
        util.exportExcel(response, list, "员工管理数据");
    }

    /**
     * 获取员工管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:stafforder:query')")
    @GetMapping(value = "/{userId}")
    public AjaxResult getInfo(@PathVariable("userId") Long userId)
    {
        return success(orderStafforderService.selectOrderStafforderByUserId(userId));
    }

    /**
     * 新增员工管理
     */
    @PreAuthorize("@ss.hasPermi('system:stafforder:add')")
    @Log(title = "员工管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody OrderStafforder orderStafforder)
    {
        return toAjax(orderStafforderService.insertOrderStafforder(orderStafforder));
    }

    /**
     * 修改员工管理
     */
    @PreAuthorize("@ss.hasPermi('system:stafforder:edit')")
    @Log(title = "员工管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody OrderStafforder orderStafforder)
    {
        return toAjax(orderStafforderService.updateOrderStafforder(orderStafforder));
    }

    /**
     * 删除员工管理
     */
    @PreAuthorize("@ss.hasPermi('system:stafforder:remove')")
    @Log(title = "员工管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userIds}")
    public AjaxResult remove(@PathVariable Long[] userIds)
    {
        return toAjax(orderStafforderService.deleteOrderStafforderByUserIds(userIds));
    }
}
